This folder contains all necessary data and scripts for replicating "Reacting to Democratization: How Authoritarian Legacies Shape Democratic Party Development"

The user will notice there are both R and Stata scripts provided. As noted in the manuscript, we used panel corrected standard errors (PCSE) in our models. While there is a package in R to calculate PCSE, its struggles with unbalanced panels. Stata, however, is very efficient in this manner, so we draw the PCSE from Stata. 

**Data Available**
gwf_panel.csv *primary panel of data using GWF for regime spells, duration, and types. 
wth_panel.csv *panel of data using WTH for regime spells, duration, and types -- see appendix C

data/stata folder hosts all output from Stata for Figures and Tables. 
stata_replication.dta *gwf_panel.csv saved in Stata format. 
stata_replication_table3.dta *slight alteration to above file to include V-Dem data on clean elections. 


GWF_clean.rdta *data prior to merging with ASP data and performing Factor Analysis to produce party institutionalization scores
WTH_clean.rdta *data prior to merging with ASP data and performing Factor Analysis to produce party institutionalization scores
asp_full.csv *data from Loxton to record presence and type of ASP
asp_leg.csv *name of ASP and seat/vote shares in the legislature
vdem_party.rds *V-Party dataset  

*all remaining data in file is output from scripts*

**Figure 1**
Begin with Figure1.do in Stata
Script will produce all models associated with the two plots in Figure 1. Output saved as Model1.#.dta to then be used in R to produce the plot
Script also produces regression_results.tex so the user can see coefficients and other relevant output for the models. 


Use figure1.R to use output from Figure1.do to produce plot with PCSE, as well as run all models and produce a plot for Random Effects. 


**Figure 2**
Begin with Figure2.do in Stata
Script will loop through 10 models varying the baseline year of comparison in the interaction term to produce a dissipation model. 

Use figure2.R to read in Stata output and produce the graphs using ggplot

**Figure 3**
Begin with Figure3.do in Stata
Script will run the interaction term and produce the marginal effect using Stata's margins

Use figure3.R to read in Stata output and produce the plots. 


**Figure 4**
Begin with Figure4.do in Stata
Script will run the interaction term and produce the marginal effect using Stata's margins

Use figure4.R to read in Stata output and produce the plots. 


**Figure 5**
Begin with Figure5.do in Stata
Script will run the interaction term and produce the marginal effect using Stata's margins

Use figure5.R to read in Stata output and produce the plots. 


**Table 2**
Table2.do produces output for non-random effects models in Table 2 (Models: 7,8,9) with PCSE
For Models 1-6, use table2.R

**Table 3**
Table3.do produces output for non-random effects models in Table 3 (Models, 2 & 4) with PCSE
For Models 1 & 3 use table3.R

**appendix_a.R**
Replicates all tables and output for Appendix A including the factor analysis. 
Factor analysis use GWF_clean.rdta and WTH_clean.rdta and is merged with asp_full.csv and asp_leg.csv to identify ASPs